----------------------------------------------------------------------------------
-- Project 2, Part 2
-- Jason Parrott
-- Rodney McGee
-- Ray
--
-- Main architecture
----------------------------------------------------------------------------------

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

entity base is
    Port (	clk : in STD_LOGIC;
			  reset : in STD_LOGIC;
			  ed : in STD_LOGIC;
			  PS2_data : inout  STD_LOGIC;
           PS2_clk : inout  STD_LOGIC;
			  LED : out std_logic_vector(7 downto 0);
           LCD_D : out  STD_LOGIC_VECTOR (11 downto 8);
           LCD_E : out  STD_LOGIC;
           LCD_RS : out  STD_LOGIC;
           LCD_RW : out  STD_LOGIC);
end base;

architecture wrapper of base is

signal keyboard_ascii : std_logic_vector (7 downto 0);
signal keyboard_ready : std_logic;
signal ascii_code : std_logic_vector (7 downto 0);
signal lcd_data_ready : std_logic;

component LCD_top
	Port ( clk : in  STD_LOGIC;
           reset : in  STD_LOGIC;
			  keyboard_data : in STD_LOGIC_VECTOR (7 downto 0);
			  keyboard_ready : in STD_LOGIC;
           LCD_D : out  STD_LOGIC_VECTOR (11 downto 8);
           LCD_E : out  STD_LOGIC;
           LCD_RS : out  STD_LOGIC;
           LCD_RW : out  STD_LOGIC);
end component;

component keyboard_top
	Port ( 
				PS2_data : inout  STD_LOGIC;
				PS2_clk : inout  STD_LOGIC;
				LED : out std_logic_vector(7 downto 0);
				clk : in  STD_LOGIC;
				reset : in  STD_LOGIC;
				data_ready : out STD_LOGIC;
				ascii_out : out  STD_LOGIC_VECTOR (7 downto 0)
				);
end component;

component program
    Port ( clk : in  STD_LOGIC;
           reset : in  STD_LOGIC;
           keyboard_ascii : in  STD_LOGIC_VECTOR (7 downto 0);
           keyboard_ready : in  STD_LOGIC;
           ascii_code : out  STD_LOGIC_VECTOR (7 downto 0);
           lcd_data_ready : out  STD_LOGIC;
           encrypt_decrypt : in  STD_LOGIC);
end component;

begin

M1: LCD_top port map(clk, reset, ascii_code, lcd_data_ready, LCD_D, LCD_E, LCD_RS, LCD_RW);
M2: Keyboard_top port map(PS2_data,PS2_clk,LED, clk, reset, keyboard_ready, keyboard_ascii);
M3: program port map(clk, reset, keyboard_ascii, keyboard_ready, ascii_code, lcd_data_ready, ed);

end wrapper;